package edu.ar.modulo2.valentinis.controller;

import java.io.IOException;
import java.util.Properties;

public abstract class Controller {

	protected static Properties config;
	
	static {
		config = new Properties(); 
			
			try {
				config.load(
						Thread.currentThread().getContextClassLoader().getResourceAsStream("controler.properties"));
			} catch (IOException e) {
				e.printStackTrace();
			}
	}
	
	public Controller() {
		
	}
	
	public abstract void excecute(String name, ParametrosAccion param);
	
	public static void callAction(String name, ParametrosAccion param) {
	
		Class clazz;
		try {
			clazz = Class.forName(config.getProperty(name+".class"));
			Controller c = (Controller) clazz.newInstance();
			c.excecute(name, param);
			
		} catch (ClassNotFoundException e) {
			
			e.printStackTrace();
		} catch (InstantiationException e) {
			
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			
			e.printStackTrace();
		}
		
		
	}
	
}
